package com.black.utils.file.compress.jar.entity;

import lombok.Getter;

import java.util.*;

/**
 * @author ylx
 */
@Getter
public class JarInfo extends JavaInfo {
    private final List<ClassInfo> classes;
    private final Map<String, ClassInfo> classMap;
    private final List<TextInfo> texts;
    private final Properties properties;
    private final PackageTreeInfo packageTreeInfo;

    public JarInfo(String name) {
        super(name);
        this.classes = new ArrayList<>();
        this.classMap = new HashMap<>();
        this.texts = new ArrayList<>();
        this.properties = new Properties();
        this.packageTreeInfo = PackageTreeInfo.root();
    }

    public void addClass(ClassInfo classInfo) {
        this.classes.add(classInfo);
        this.classMap.put(classInfo.name, classInfo);
        this.packageTreeInfo.addClass(classInfo);
    }

    public void addText(TextInfo textInfo) {
        this.texts.add(textInfo);
    }

    public void addProperties(Properties properties) {
        this.properties.putAll(properties);
    }

    public ClassInfo getClass(String className) {
        return this.classMap.get(className);
    }
}
